<html>
<head><meta charset="utf-8"><title>What is a DefKind::variant · t-compiler/help · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/index.html">t-compiler/help</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/What.20is.20a.20DefKind.3A.3Avariant.html">What is a DefKind::variant</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="227028503"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/What%20is%20a%20DefKind%3A%3Avariant/near/227028503" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Robin Moussu <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/What.20is.20a.20DefKind.3A.3Avariant.html#227028503">(Feb 19 2021 at 21:07)</a>:</h4>
<p>In the enum <a href="https://doc.rust-lang.org/nightly/nightly-rustc/rustc_hir/def/enum.DefKind.html"><code>DefKind</code></a>, one of the possible value is <code>Variant</code>. What is this?</p>



<a name="227028893"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/What%20is%20a%20DefKind%3A%3Avariant/near/227028893" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> cjgillot <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/What.20is.20a.20DefKind.3A.3Avariant.html#227028893">(Feb 19 2021 at 21:10)</a>:</h4>
<p>It's an enum variant. <code>rustc_middle::hir::map::Map::def_kind</code> assigns the DepKinds to the HIR nodes.</p>



<a name="227029032"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/What%20is%20a%20DefKind%3A%3Avariant/near/227029032" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Robin Moussu <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/What.20is.20a.20DefKind.3A.3Avariant.html#227029032">(Feb 19 2021 at 21:11)</a>:</h4>
<p>Ah, so a rust enum has kind <code>Enum</code>, and it has two parts, the <code>Union</code> and the <code>Variant</code> ?</p>



<a name="227029549"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/What%20is%20a%20DefKind%3A%3Avariant/near/227029549" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> cjgillot <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/What.20is.20a.20DefKind.3A.3Avariant.html#227029549">(Feb 19 2021 at 21:14)</a>:</h4>
<p>No. A rust enum has kind <code>Enum</code>. It is composed of several <code>Variant</code>s that contain <code>Field</code>s.<br>
A struct has kind <code>Struct</code> and an union has kind <code>Union</code>. Those contain several <code>Field</code>s.</p>



<a name="227029703"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/What%20is%20a%20DefKind%3A%3Avariant/near/227029703" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Robin Moussu <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/What.20is.20a.20DefKind.3A.3Avariant.html#227029703">(Feb 19 2021 at 21:15)</a>:</h4>
<p>ok, thanks for the explanation. It’s much clearer.</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>